{php $CSS = array('buy-index');}
{template 'header'}

<style>
body{padding:0;margin-top:-15px;}
</style>

<DIV id=header></DIV>
<div class="m" id="page">
	<div id="aliGlobalCrumb" class="crumb global">
			Locate: <a href="{DT_PATH}">home</a>
			&gt;
			<a href="{$MOD[linkurl]}">{$MOD[name]}</a>
			&gt;
			<h2><a href="{$MOD[linkurl]}{$linkurl}">All Categories</a></h2>
	</div>

{if $DT[page_catalog]}
	<div id="toc">
		<span class="toc-caption">Products by Categories:</span>
	</div>

	{php $mid = 5; $cols = 1;}
	{php $precent = ceil(100/$cols);}
	{php $CATEGORY = cache_read('category-'.$moduleid.'.php');}
	{php $CATALOG = array();}

	{php $ss=""; $LETTER = array('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'); $LETTER_l=count($LETTER);}

	{php for($a=0;$a<$LETTER_l;$a++){ }

    {php     $num=0; $word=array(); }
    {php     $ss.="<a rel='nofollow' href='#letter-" . $LETTER[$a] ."'>"; $s1=""; }
	{php     for($b=0; $num<6 && $b<$LETTER_l; $b++){ }
	{php         $has=0; $word[]=$LETTER[$a];  }
	{php         foreach($CATEGORY as $kk=>$vv) { }
	{php 	        if($vv['letter'] == $LETTER[$a] && $vv['parentid']==0) {  }
	{php 	            $num++; $has++;  }
	{php            } }
	{php         } }
	{php 	     if($has==0) { $ss.="<span>" . $LETTER[$a] . "</span> "; }else{$ss.=$LETTER[$a] . " "; } }
	{php         $s1.=$LETTER[$a] . " ";$a++; }
	{php     } }
    {php     $ss.="</a>"; }
    {php     if($a<$LETTER_l) $ss.="<span class='separator'>|</span>"; }

	<div class="section" id="letter-{php echo $word[0]; }">
	    {php if($a>0) echo "<a href='#' rel='nofollow' class='back-to-top'>Back to Top</a>"; }
	    <span class="sec-caption">{php echo $s1}</span>
		<div class="sec-content clearfix">

		<div class="dsn" id="catalog_index" onmouseout="index_leave(this, event);"></div>
		<div class="catalog c_b">		
		<div id="catalog">
		</div>
		</div>
		<div class="b10 c_b"></div>

			{php foreach($word as $k=>$v) { }

	        {php     $letter=$word[$k];}
			{php     foreach($CATEGORY as $k1=>$v1) { }
			{php 	    if($v1['letter'] == $letter && $v1['parentid']==0) { }
			{php            $table = $DT_PRE.'buy';}
			{php            $r = $db->get_one("SELECT count(*) as num FROM $table WHERE catid=".$v1['catid'], 'CACHE');}
						<div class="sec-categories clearfix"> <a href="{$v1['linkurl']}" class="main-category">{$v1['catname']}</a> ({$r['num']})
							<ul>
							{php $i=0; }
							{php foreach($CATEGORY as $k2=>$v2) { }
			                {php     if($v2['parentid']==$v1['catid']) { }
			                {php         $i++; }
			                {php         if ($i==9){ }
											 <li><a rel="nofollow" class="more-link">More...</a></li>
											 <ul class="more-categories">
			                {php         } }
											 <li><a href="{$v2['linkurl']}">{$v2['catname']}</a></li>
			                {php     } }
			                {php } }
			                {php if ($i>8){ }
								    </ul>
			                {php } }
							</ul>
						</div>
			{php 	    } }
			{php     } }
			{php } }

		</div>
	</div>

	{php }  }

	<script>$("#toc").append("{php echo $ss; }");</script>

{/if}
</div>

<script type="text/javascript" src="../skin/en/categories.js"></script>

{template 'footer'}